﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed
#pragma once

#include "GcmpModelInterface.h"
#include "IDbObject.h"
#include <vector>
#include "OwnerPtr.h"
#include "UniIdentity.h"

namespace gcmp
{
    class IParameter;
    class IDocument;

    /// \brief  族类型接口类
    ///
    /// \see IFamily
    class GCMP_MODEL_INTERFACE_EXPORT IFamilyType : public IDbObject
    {
        DEFINE_CAST_DERIVED(IFamilyType, IDbObject)
    public:
        /// \brief 创建新族类型
        ///
        /// 以pOtherFamilyType为模板，创建一个名为newFamilyTypeName的新族类型
        /// \param newFamilyTypeName 族类型名字
        /// \param pOtherFamilyType 族类型对象
        /// \return 族类型
        static OwnerPtr<IFamilyType> Create(const std::wstring& newFamilyTypeName, 
            const IFamilyType* pOtherFamilyType);

        /// \brief 创建新族类型
        ///
        /// 以pOtherFamilyType为模板，创建一个名为newFamilyTypeName的新族类型
        /// \param newFamilyTypeName 族类型名字
        /// \param pOtherFamilyType 族类型对象
        /// \param newFamilyTypeUid 新族类型的Uid
        /// \return 族类型
        static OwnerPtr<IFamilyType> Create(const std::wstring& newFamilyTypeName,
            const IFamilyType* pOtherFamilyType, const UniIdentity& newFamilyTypeUid);

        /// \brief 返回族类型名字
        ///
        /// \return 族类型名字
        virtual const std::wstring& GetName() const = 0;

        /// \brief 设置族类型名字
        ///
        /// \param familyTypeName 族类别名字
        /// \return 成功返回true，失败返回false
        virtual bool SetName(const std::wstring& familyTypeName) = 0;

        /// \brief 返回族类型中的所有参数对象
        ///
        /// \return 参数对象数组
        virtual const std::vector<OwnerPtr<IParameter>> GetFamilyParameters() const = 0;

        /// \brief 返回族类型中的参数对象
        ///
        /// \param parameterDefinitionId 族参数定义Id
        /// \return 参数对象
        virtual const IParameter* GetFamilyParameter(int parameterDefinitionId) const = 0;

        /// \brief 设置参数值
        ///
        /// \param pDocument 文档指针
        /// \param pParam参数对象
        /// \return 成功返回true，失败返回false
        virtual bool SetFamilyParameter(IDocument* pDocument, const IParameter* pParam) = 0;

        /// \brief 获取族类型的Uid
        ///
        /// \return 返回族类型的Uid
        virtual const UniIdentity& GetFamilyTypeUid() const = 0;

        /// \brief 设置族类型的Uid
        ///
        /// \param Uid 族类型的Uid
        /// \return void
        /// \note 提供该接口用于文档升级，不建议其他情况使用该接口
        virtual void SetFamilyTypeUid(const UniIdentity& Uid) = 0;
    };
}

